package com.gjj.echarts.echartsgjj.service.impl;

import com.gjj.echarts.echartsgjj.mapper.GjjTableRetentionpaymentMapper;
import com.gjj.echarts.echartsgjj.pojo.GjjTableRetentionpayment;
import com.gjj.echarts.echartsgjj.service.RetentionPaymentService;
import com.gjj.echarts.echartsgjj.vo.RetentionpaymentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RetentionPaymentServiceImpl implements RetentionPaymentService {
    @Autowired
    GjjTableRetentionpaymentMapper retentionpaymentMapper;
    @Override
    public RetentionpaymentVo getRetentionPaymentForOneMonth(Integer month) {
        List<GjjTableRetentionpayment> retentionpayments = retentionpaymentMapper.getForOneMonth(month);

        RetentionpaymentVo vo = new RetentionpaymentVo();
        for (GjjTableRetentionpayment retentionpayment : retentionpayments) {
            if (retentionpayment.getType().equals("客户端")){
                vo.setClient(retentionpayment.getPrice());
                vo.setClientUnit(retentionpayment.getUnitQuantity());
                vo.setClientPeople(retentionpayment.getPeople());
            }else if (retentionpayment.getType().equals("人力资源公司")){
                vo.setCompany(retentionpayment.getPrice());
                vo.setCompanyUnit(retentionpayment.getUnitQuantity());
                vo.setCompanyPeople(retentionpayment.getPeople());
            }else {
                vo.setWebpage(retentionpayment.getPrice());
                vo.setWebpageUnit(retentionpayment.getUnitQuantity());
                vo.setWebpagePeople(retentionpayment.getPeople());
            }
        }
        return vo;
    }
}
